package com.peaksport.framework.base.venum;

import javax.persistence.AttributeConverter;
import javax.persistence.Converter;

/**
 * 状态枚举(整型)转换类
 * 
 * @author jinbin_guo  2019年4月16日 下午4:40:14
 *
 */
@Converter
public class BaseIntConverter implements AttributeConverter<BaseIntEnum,Integer> {

    @Override
    public Integer convertToDatabaseColumn(BaseIntEnum attribute) {
    	if (attribute == null) return 0;
        return attribute.getValue();
    }

    @Override
    public BaseIntEnum convertToEntityAttribute(Integer dbData) {
        return new BaseIntEnum(dbData);
    }
}
